package com.dmgis.qxfw.dataservice.businessservice.yyhb.service.Impl;

import com.dmgis.qxfw.dataservice.businessservice.api.domain.DbConfig;
import com.dmgis.qxfw.dataservice.businessservice.api.domain.RequestDataBySelect;
import com.dmgis.qxfw.dataservice.businessservice.api.entity.zy.airpollution;
import com.dmgis.qxfw.dataservice.businessservice.api.entity.zy.sum_atmospheric_day_data;
import com.dmgis.qxfw.dataservice.businessservice.common.pojo.AllCityInfo;
import com.dmgis.qxfw.dataservice.businessservice.common.util.JsonUtil;
import com.dmgis.qxfw.dataservice.businessservice.common.util.StringUtil;
import com.dmgis.qxfw.dataservice.businessservice.controller.ProcessRequestController;
import com.dmgis.qxfw.dataservice.businessservice.yyhb.service.EnvirMonitorServiceI;
import com.fasterxml.jackson.core.type.TypeReference;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class EnvirMonitorServiceImpl implements EnvirMonitorServiceI {

	ProcessRequestController procon=new ProcessRequestController();

	@Override
	public Date allCityInitTime() {
		Date date=new Date();
		Map<String, String> selectParam = new HashMap<String, String>();
		RequestDataBySelect selectRequest = new RequestDataBySelect();
		String[] columns = new String[] { "to_char(observtime, 'yyyy-MM-dd HH24:MI:SS') as observtime"};
		selectRequest.setColumns(columns);
		selectRequest.setSort(new String[] { "observtime desc"});
		selectRequest.setParam(String.format("stationid='%s'","Qs"));
		selectRequest.setLimit(1);
		try {
			selectParam.put("method", "airpollution");
			selectParam.put("sqlType", "select");
			selectParam.put("advCode", DbConfig.advCode);
			selectParam.put("param", JsonUtil.object2Json(selectRequest));
			String message = procon.processRequest(selectParam);
			date = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<airpollution>>() {
			}).get(0).getObservtime();
		} catch (Exception e) {
			// TODO: handle exception
		}
		return date;
	}

	@Override
	public List<AllCityInfo> allCityInfo(String startTime, String endTime, String b) {
		List<airpollution> listData=new ArrayList<airpollution>();
		List<sum_atmospheric_day_data> listdayData=new ArrayList<sum_atmospheric_day_data>();
		List<AllCityInfo> resultList=new ArrayList<AllCityInfo>();
		Map<String, String> selectParam = new HashMap<String, String>();
		RequestDataBySelect selectRequest = new RequestDataBySelect();
		List<String> columns = new ArrayList<String>();
		columns.add("stationid");
		columns.add("to_char(observtime, 'yyyy-MM-dd HH24:MI:SS') as observtime");
		columns.add("longitude");
		columns.add("latitude");
		columns.add("altitude");
		columns.add("stationname");
		columns.add("aqi");
		columns.add("firstpollution");
		columns.add("pollutionlevel");
		columns.add("concenpm2p5");
		columns.add("fractpm2p5");
		columns.add("concenpm10");
		columns.add("fractpm10");
		columns.add("concenco");
		columns.add("fractco");
		columns.add("conceno3");
		columns.add("fracto3");
		columns.add("conceno38h");
		columns.add("fracto38h");
		columns.add("concenso2");
		columns.add("fractso2");
		columns.add("concenno2");
		columns.add("fractno2");
		// 拼接where字段
		StringBuilder strWhere = new StringBuilder();
		int whereCount = 0;
		if (startTime!=null) {
			strWhere.append(String.format(" and observtime>='%s'",startTime));
		}
		if (endTime!=null) {
			strWhere.append(String.format(" and observtime<='%s'",endTime));
		}
		strWhere.append(String.format(" and stationid !='%s'","Qs"));
		if (whereCount == 0 && !StringUtil.IsNullOrEmpty(strWhere.toString())) {
			strWhere = strWhere.replace(0, 4, "");
		}
		selectRequest.setParam(strWhere.toString());
		if (!StringUtil.IsNullOrEmpty(b) && b.contains("AirPollution")) {
			columns.add("concenpm2p524");
			columns.add("concenpm1024");
			selectRequest.setColumns(columns.toArray(new String[columns.size()]));
			try {
				selectParam.put("method", "airpollution");
				selectParam.put("sqlType", "select");
				selectParam.put("advCode", DbConfig.advCode);
				selectParam.put("param", JsonUtil.object2Json(selectRequest));
				String message = procon.processRequest(selectParam);
				listData = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<airpollution>>() {
				});
			} catch (Exception e) {
				// TODO: handle exception
			}
			if (listData!=null&&listData.size()>0) {
				for (airpollution air : listData) {
					AllCityInfo cityinfo=new AllCityInfo();
					cityinfo.setStationID(air.getStationid());
					cityinfo.setObservTime(air.getObservtime());
					cityinfo.setLongitude(air.getLongitude());
					cityinfo.setLatitude(air.getLatitude());
					cityinfo.setAltitude(air.getAltitude());
					cityinfo.setStationName(air.getStationname());
					cityinfo.setAQI(air.getAqi());
					cityinfo.setFirstPollution(air.getFirstpollution());
					cityinfo.setPollutionLevel(air.getPollutionlevel());
					cityinfo.setConcenPM2p5(air.getConcenpm2p5());
					cityinfo.setConcenPM2p5_24(air.getConcenpm2p5_24());
					cityinfo.setFractPM2p5(air.getFractpm2p5());
					cityinfo.setConcenPM10(air.getConcenpm10());
					cityinfo.setConcenPM10_24(air.getConcenpm10_24());
					cityinfo.setFractPM10(air.getFractpm10());
					cityinfo.setConcenCO(air.getConcenco());
					cityinfo.setFractCO(air.getFractco());
					cityinfo.setConcenO3(air.getConceno3());
					cityinfo.setFractO3(air.getFracto3());
					cityinfo.setConcenO38H(air.getConceno38h());
					cityinfo.setFractO38H(air.getFracto38h());
					cityinfo.setConcenSO2(air.getConcenso2());
					cityinfo.setFractSO2(air.getFractso2());
					cityinfo.setConcenNO2(air.getConcenno2());
					cityinfo.setFractNO2(air.getFractno2());
					resultList.add(cityinfo);
				}
			}
		}
		if (!StringUtil.IsNullOrEmpty(b) && b.contains("大气日数据汇总表")) {
			selectRequest.setColumns(columns.toArray(new String[columns.size()]));
			try {
				selectParam.put("method", "sum_atmospheric_day_data");
				selectParam.put("sqlType", "select");
				selectParam.put("advCode", DbConfig.advCode);
				selectParam.put("param", JsonUtil.object2Json(selectRequest));
				String message = procon.processRequest(selectParam);
				listdayData = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<sum_atmospheric_day_data>>() {
				});
			} catch (Exception e) {
				// TODO: handle exception
			}
			if (listdayData!=null&&listdayData.size()>0) {
				for (sum_atmospheric_day_data air : listdayData) {
					AllCityInfo cityinfo=new AllCityInfo();
					cityinfo.setStationID(air.getStationid());
					cityinfo.setObservTime(air.getObservtime());
					cityinfo.setLongitude(air.getLongitude());
					cityinfo.setLatitude(air.getLatitude());
					cityinfo.setAltitude(air.getAltitude());
					cityinfo.setStationName(air.getStationname());
					cityinfo.setAQI(air.getAqi());
					cityinfo.setFirstPollution(air.getFirstpollution());
					cityinfo.setPollutionLevel(air.getPollutionlevel());
					cityinfo.setConcenPM2p5(air.getConcenpm2p5());
					cityinfo.setFractPM2p5(air.getFractpm2p5());
					cityinfo.setConcenPM10(air.getConcenpm10());
					cityinfo.setFractPM10(air.getFractpm10());
					cityinfo.setConcenCO(air.getConcenco());
					cityinfo.setFractCO(air.getFractco());
					cityinfo.setConcenO3(air.getConceno3());
					cityinfo.setFractO3(air.getFracto3());
					cityinfo.setConcenO38H(air.getConceno38h());
					cityinfo.setFractO38H(air.getFracto38h());
					cityinfo.setConcenSO2(air.getConcenso2());
					cityinfo.setFractSO2(air.getFractso2());
					cityinfo.setConcenNO2(air.getConcenno2());
					cityinfo.setFractNO2(air.getFractno2());
					resultList.add(cityinfo);
				}
			}
		}
		return resultList;
	}



	@Override
	public Date everyCityInitTime() {
		Date date = new Date();
		Map<String, String> selectParam = new HashMap<String, String>();
		RequestDataBySelect selectRequest = new RequestDataBySelect();
		String[] columns = new String[]{"to_char(observtime, 'yyyy-MM-dd HH24:MI:SS') as observtime"};
		selectRequest.setColumns(columns);
		selectRequest.setSort(new String[]{"observtime desc"});
		selectRequest.setLimit(1);
		selectRequest.setParam("stationid!='Qs'");
		try {
			selectParam.put("method", "airpollution");
			selectParam.put("sqlType", "select");
			selectParam.put("advCode", DbConfig.advCode);
			selectParam.put("param", JsonUtil.object2Json(selectRequest));
			String message =procon.processRequest(selectParam);
			date = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<airpollution>>() {
			}).get(0).getObservtime();
		} catch (Exception e) {
			// TODO: handle exception
		}
		return date;
	}




	public List<AllCityInfo> allCityInfo1(String startTime,String b) {
		List<airpollution> listData=new ArrayList<airpollution>();
		List<sum_atmospheric_day_data> listdayData=new ArrayList<sum_atmospheric_day_data>();
		List<AllCityInfo> resultList=new ArrayList<AllCityInfo>();
		Map<String, String> selectParam = new HashMap<String, String>();
		RequestDataBySelect selectRequest = new RequestDataBySelect();
		List<String> columns = new ArrayList<String>();
		columns.add("stationid");
		columns.add("to_char(observtime, 'yyyy-MM-dd HH24:MI:SS') as observtime");
		columns.add("longitude");
		columns.add("latitude");
		columns.add("altitude");
		columns.add("stationname");
		columns.add("aqi");
		columns.add("firstpollution");
		columns.add("pollutionlevel");
		columns.add("concenpm2p5");
		columns.add("fractpm2p5");
		columns.add("concenpm10");
		columns.add("fractpm10");
		columns.add("concenco");
		columns.add("fractco");
		columns.add("conceno3");
		columns.add("fracto3");
		columns.add("conceno38h");
		columns.add("fracto38h");
		columns.add("concenso2");
		columns.add("fractso2");
		columns.add("concenno2");
		columns.add("fractno2");
		// 拼接where字段
		StringBuilder strWhere = new StringBuilder();
		int whereCount = 0;
		if (startTime!=null) {
			strWhere.append(String.format(" and observtime='%s'",startTime));
		}
		strWhere.append(String.format(" and stationid='%s'","Qs"));
		if (whereCount == 0 && !StringUtil.IsNullOrEmpty(strWhere.toString())) {
			strWhere = strWhere.replace(0, 4, "");
		}
		selectRequest.setParam(strWhere.toString());
		if (!StringUtil.IsNullOrEmpty(b) && b.contains("AirPollution")) {
			columns.add("concenpm2p524");
			columns.add("concenpm1024");
			selectRequest.setColumns(columns.toArray(new String[columns.size()]));
			try {
				selectParam.put("method", "airpollution");
				selectParam.put("sqlType", "select");
				selectParam.put("advCode", DbConfig.advCode);
				selectParam.put("param", JsonUtil.object2Json(selectRequest));
				String message = procon.processRequest(selectParam);
				listData = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<airpollution>>() {
				});
			} catch (Exception e) {
				// TODO: handle exception
			}
			if (listData!=null&&listData.size()>0) {
				for (airpollution air : listData) {
					AllCityInfo cityinfo=new AllCityInfo();
					cityinfo.setStationID(air.getStationid());
					cityinfo.setObservTime(air.getObservtime());
					cityinfo.setLongitude(air.getLongitude());
					cityinfo.setLatitude(air.getLatitude());
					cityinfo.setAltitude(air.getAltitude());
					cityinfo.setStationName(air.getStationname());
					cityinfo.setAQI(air.getAqi());
					cityinfo.setFirstPollution(air.getFirstpollution());
					cityinfo.setPollutionLevel(air.getPollutionlevel());
					cityinfo.setConcenPM2p5(air.getConcenpm2p5());
					cityinfo.setConcenPM2p5_24(air.getConcenpm2p5_24());
					cityinfo.setFractPM2p5(air.getFractpm2p5());
					cityinfo.setConcenPM10(air.getConcenpm10());
					cityinfo.setConcenPM10_24(air.getConcenpm10_24());
					cityinfo.setFractPM10(air.getFractpm10());
					cityinfo.setConcenCO(air.getConcenco());
					cityinfo.setFractCO(air.getFractco());
					cityinfo.setConcenO3(air.getConceno3());
					cityinfo.setFractO3(air.getFracto3());
					cityinfo.setConcenO38H(air.getConceno38h());
					cityinfo.setFractO38H(air.getFracto38h());
					cityinfo.setConcenSO2(air.getConcenso2());
					cityinfo.setFractSO2(air.getFractso2());
					cityinfo.setConcenNO2(air.getConcenno2());
					cityinfo.setFractNO2(air.getFractno2());
					resultList.add(cityinfo);
				}
			}
		}
		if (!StringUtil.IsNullOrEmpty(b) && b.contains("大气日数据汇总表")) {
			selectRequest.setColumns(columns.toArray(new String[columns.size()]));
			try {
				selectParam.put("method", "sum_atmospheric_day_data");
				selectParam.put("sqlType", "select");
				selectParam.put("advCode", DbConfig.advCode);
				selectParam.put("param", JsonUtil.object2Json(selectRequest));
				String message =procon.processRequest(selectParam);
				listdayData = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<sum_atmospheric_day_data>>() {
				});
			} catch (Exception e) {
				// TODO: handle exception
			}
			if (listdayData!=null&&listdayData.size()>0) {
				for (sum_atmospheric_day_data air : listdayData) {
					AllCityInfo cityinfo=new AllCityInfo();
					cityinfo.setStationID(air.getStationid());
					cityinfo.setObservTime(air.getObservtime());
					cityinfo.setLongitude(air.getLongitude());
					cityinfo.setLatitude(air.getLatitude());
					cityinfo.setAltitude(air.getAltitude());
					cityinfo.setStationName(air.getStationname());
					cityinfo.setAQI(air.getAqi());
					cityinfo.setFirstPollution(air.getFirstpollution());
					cityinfo.setPollutionLevel(air.getPollutionlevel());
					cityinfo.setConcenPM2p5(air.getConcenpm2p5());
					cityinfo.setFractPM2p5(air.getFractpm2p5());
					cityinfo.setConcenPM10(air.getConcenpm10());
					cityinfo.setFractPM10(air.getFractpm10());
					cityinfo.setConcenCO(air.getConcenco());
					cityinfo.setFractCO(air.getFractco());
					cityinfo.setConcenO3(air.getConceno3());
					cityinfo.setFractO3(air.getFracto3());
					cityinfo.setConcenO38H(air.getConceno38h());
					cityinfo.setFractO38H(air.getFracto38h());
					cityinfo.setConcenSO2(air.getConcenso2());
					cityinfo.setFractSO2(air.getFractso2());
					cityinfo.setConcenNO2(air.getConcenno2());
					cityinfo.setFractNO2(air.getFractno2());
					resultList.add(cityinfo);
				}
			}
		}
		return resultList;
	}
	@Override
	public List<AllCityInfo> getEveryStationInfo(String startTime, String endTime, String b) {
		List<airpollution> listData=new ArrayList<airpollution>();
		List<sum_atmospheric_day_data> listdayData=new ArrayList<sum_atmospheric_day_data>();
		List<AllCityInfo> resultList=new ArrayList<AllCityInfo>();
		Map<String, String> selectParam = new HashMap<String, String>();
		RequestDataBySelect selectRequest = new RequestDataBySelect();
		List<String> columns = new ArrayList<String>();
		columns.add("stationid");
		columns.add("to_char(observtime, 'yyyy-MM-dd HH24:MI:SS') as observtime");
		columns.add("longitude");
		columns.add("latitude");
		columns.add("altitude");
		columns.add("stationname");
		columns.add("aqi");
		columns.add("firstpollution");
		columns.add("pollutionlevel");
		columns.add("concenpm2p5");
		columns.add("fractpm2p5");
		columns.add("concenpm10");
		columns.add("fractpm10");
		columns.add("concenco");
		columns.add("fractco");
		columns.add("conceno3");
		columns.add("fracto3");
		columns.add("conceno38h");
		columns.add("fracto38h");
		columns.add("concenso2");
		columns.add("fractso2");
		columns.add("concenno2");
		columns.add("fractno2");
		// 拼接where字段
		StringBuilder strWhere = new StringBuilder();
		int whereCount = 0;
		if (startTime!=null) {
			strWhere.append(String.format(" and observtime>='%s'",startTime));
		}
		if (endTime!=null) {
			strWhere.append(String.format(" and observtime<='%s'",endTime));
		}
		strWhere.append(String.format(" and stationid!='%s'","Qs"));
		if (whereCount == 0 && !StringUtil.IsNullOrEmpty(strWhere.toString())) {
			strWhere = strWhere.replace(0, 4, "");
		}
		selectRequest.setParam(strWhere.toString());
		if (!StringUtil.IsNullOrEmpty(b) && b.contains("AirPollution")) {
			columns.add("concenpm2p524");
			columns.add("concenpm1024");
			selectRequest.setColumns(columns.toArray(new String[columns.size()]));
			selectRequest.setSort(new String[]{"observtime"});
			try {
				selectParam.put("method", "airpollution");
				selectParam.put("sqlType", "select");
				selectParam.put("advCode", DbConfig.advCode);
				selectParam.put("param", JsonUtil.object2Json(selectRequest));
				String message =procon.processRequest(selectParam);
				listData = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<airpollution>>() {
				});
			} catch (Exception e) {
				// TODO: handle exception
			}
			if (listData!=null&&listData.size()>0) {
				for (airpollution air : listData) {
					AllCityInfo cityinfo=new AllCityInfo();
					cityinfo.setStationID(air.getStationid());
					cityinfo.setObservTime(air.getObservtime());
					cityinfo.setLongitude(air.getLongitude());
					cityinfo.setLatitude(air.getLatitude());
					cityinfo.setAltitude(air.getAltitude());
					cityinfo.setStationName(air.getStationname());
					cityinfo.setAQI(air.getAqi());
					cityinfo.setFirstPollution(air.getFirstpollution());
					cityinfo.setPollutionLevel(air.getPollutionlevel());
					cityinfo.setConcenPM2p5(air.getConcenpm2p5());
					cityinfo.setConcenPM2p5_24(air.getConcenpm2p5_24());
					cityinfo.setFractPM2p5(air.getFractpm2p5());
					cityinfo.setConcenPM10(air.getConcenpm10());
					cityinfo.setConcenPM10_24(air.getConcenpm10_24());
					cityinfo.setFractPM10(air.getFractpm10());
					cityinfo.setConcenCO(air.getConcenco());
					cityinfo.setFractCO(air.getFractco());
					cityinfo.setConcenO3(air.getConceno3());
					cityinfo.setFractO3(air.getFracto3());
					cityinfo.setConcenO38H(air.getConceno38h());
					cityinfo.setFractO38H(air.getFracto38h());
					cityinfo.setConcenSO2(air.getConcenso2());
					cityinfo.setFractSO2(air.getFractso2());
					cityinfo.setConcenNO2(air.getConcenno2());
					cityinfo.setFractNO2(air.getFractno2());
					resultList.add(cityinfo);
				}
			}
		}
		if (!StringUtil.IsNullOrEmpty(b) && b.contains("大气日数据汇总表")) {
			selectRequest.setColumns(columns.toArray(new String[columns.size()]));
			selectRequest.setSort(new String[]{"observtime"});
			try {
				selectParam.put("method", "sum_atmospheric_day_data");
				selectParam.put("sqlType", "select");
				selectParam.put("advCode", DbConfig.advCode);
				selectParam.put("param", JsonUtil.object2Json(selectRequest));
				String message = procon.processRequest(selectParam);
				listdayData = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<sum_atmospheric_day_data>>() {
				});
			} catch (Exception e) {
				// TODO: handle exception
			}
			if (listdayData!=null&&listdayData.size()>0) {
				for (sum_atmospheric_day_data air : listdayData) {
					AllCityInfo cityinfo=new AllCityInfo();
					cityinfo.setStationID(air.getStationid());
					cityinfo.setObservTime(air.getObservtime());
					cityinfo.setLongitude(air.getLongitude());
					cityinfo.setLatitude(air.getLatitude());
					cityinfo.setAltitude(air.getAltitude());
					cityinfo.setStationName(air.getStationname());
					cityinfo.setAQI(air.getAqi());
					cityinfo.setFirstPollution(air.getFirstpollution());
					cityinfo.setPollutionLevel(air.getPollutionlevel());
					cityinfo.setConcenPM2p5(air.getConcenpm2p5());
					cityinfo.setFractPM2p5(air.getFractpm2p5());
					cityinfo.setConcenPM10(air.getConcenpm10());
					cityinfo.setFractPM10(air.getFractpm10());
					cityinfo.setConcenCO(air.getConcenco());
					cityinfo.setFractCO(air.getFractco());
					cityinfo.setConcenO3(air.getConceno3());
					cityinfo.setFractO3(air.getFracto3());
					cityinfo.setConcenO38H(air.getConceno38h());
					cityinfo.setFractO38H(air.getFracto38h());
					cityinfo.setConcenSO2(air.getConcenso2());
					cityinfo.setFractSO2(air.getFractso2());
					cityinfo.setConcenNO2(air.getConcenno2());
					cityinfo.setFractNO2(air.getFractno2());
					resultList.add(cityinfo);
				}
			}
		}
		return resultList;
	}
	@Override
	public List<AllCityInfo> getEveryStationInfo1(String startTime, String b) {
		List<airpollution> listData=new ArrayList<airpollution>();
		List<sum_atmospheric_day_data> listdayData=new ArrayList<sum_atmospheric_day_data>();
		List<AllCityInfo> resultList=new ArrayList<AllCityInfo>();
		Map<String, String> selectParam = new HashMap<String, String>();
		RequestDataBySelect selectRequest = new RequestDataBySelect();
		List<String> columns = new ArrayList<String>();
		columns.add("stationid");
		columns.add("to_char(observtime, 'yyyy-MM-dd HH24:MI:SS') as observtime");
		columns.add("longitude");
		columns.add("latitude");
		columns.add("altitude");
		columns.add("stationname");
		columns.add("aqi");
		columns.add("firstpollution");
		columns.add("pollutionlevel");
		columns.add("concenpm2p5");
		columns.add("fractpm2p5");
		columns.add("concenpm10");
		columns.add("fractpm10");
		columns.add("concenco");
		columns.add("fractco");
		columns.add("conceno3");
		columns.add("fracto3");
		columns.add("conceno38h");
		columns.add("fracto38h");
		columns.add("concenso2");
		columns.add("fractso2");
		columns.add("concenno2");
		columns.add("fractno2");
		// 拼接where字段
		StringBuilder strWhere = new StringBuilder();
		int whereCount = 0;
		if (startTime!=null) {
			strWhere.append(String.format(" and observtime='%s'",startTime));
		}
		strWhere.append(String.format(" and stationid!='%s'","Qs"));
		if (whereCount == 0 && !StringUtil.IsNullOrEmpty(strWhere.toString())) {
			strWhere = strWhere.replace(0, 4, "");
		}
		selectRequest.setParam(strWhere.toString());
		if (!StringUtil.IsNullOrEmpty(b) && b.contains("AirPollution")) {
			columns.add("concenpm2p524");
			columns.add("concenpm1024");
			selectRequest.setColumns(columns.toArray(new String[columns.size()]));
			selectRequest.setSort(new String[]{"observtime"});
			try {
				selectParam.put("method", "airpollution");
				selectParam.put("sqlType", "select");
				selectParam.put("advCode", DbConfig.advCode);
				selectParam.put("param", JsonUtil.object2Json(selectRequest));
				String message =procon.processRequest(selectParam);
				listData = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<airpollution>>() {
				});
			} catch (Exception e) {
				// TODO: handle exception
			}
			if (listData!=null&&listData.size()>0) {
				for (airpollution air : listData) {
					AllCityInfo cityinfo=new AllCityInfo();
					cityinfo.setStationID(air.getStationid());
					cityinfo.setObservTime(air.getObservtime());
					cityinfo.setLongitude(air.getLongitude());
					cityinfo.setLatitude(air.getLatitude());
					cityinfo.setAltitude(air.getAltitude());
					cityinfo.setStationName(air.getStationname());
					cityinfo.setAQI(air.getAqi());
					cityinfo.setFirstPollution(air.getFirstpollution());
					cityinfo.setPollutionLevel(air.getPollutionlevel());
					cityinfo.setConcenPM2p5(air.getConcenpm2p5());
					cityinfo.setConcenPM2p5_24(air.getConcenpm2p5_24());
					cityinfo.setFractPM2p5(air.getFractpm2p5());
					cityinfo.setConcenPM10(air.getConcenpm10());
					cityinfo.setConcenPM10_24(air.getConcenpm10_24());
					cityinfo.setFractPM10(air.getFractpm10());
					cityinfo.setConcenCO(air.getConcenco());
					cityinfo.setFractCO(air.getFractco());
					cityinfo.setConcenO3(air.getConceno3());
					cityinfo.setFractO3(air.getFracto3());
					cityinfo.setConcenO38H(air.getConceno38h());
					cityinfo.setFractO38H(air.getFracto38h());
					cityinfo.setConcenSO2(air.getConcenso2());
					cityinfo.setFractSO2(air.getFractso2());
					cityinfo.setConcenNO2(air.getConcenno2());
					cityinfo.setFractNO2(air.getFractno2());
					resultList.add(cityinfo);
				}
			}
		}
		if (!StringUtil.IsNullOrEmpty(b) && b.contains("大气日数据汇总表")) {
			selectRequest.setColumns(columns.toArray(new String[columns.size()]));
			selectRequest.setSort(new String[]{"observtime"});
			try {
				selectParam.put("method", "sum_atmospheric_day_data");
				selectParam.put("sqlType", "select");
				selectParam.put("advCode", DbConfig.advCode);
				selectParam.put("param", JsonUtil.object2Json(selectRequest));
				String message =procon.processRequest(selectParam);
				listdayData = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<sum_atmospheric_day_data>>() {
				});
			} catch (Exception e) {
				// TODO: handle exception
			}
			if (listdayData!=null&&listdayData.size()>0) {
				for (sum_atmospheric_day_data air : listdayData) {
					AllCityInfo cityinfo=new AllCityInfo();
					cityinfo.setStationID(air.getStationid());
					cityinfo.setObservTime(air.getObservtime());
					cityinfo.setLongitude(air.getLongitude());
					cityinfo.setLatitude(air.getLatitude());
					cityinfo.setAltitude(air.getAltitude());
					cityinfo.setStationName(air.getStationname());
					cityinfo.setAQI(air.getAqi());
					cityinfo.setFirstPollution(air.getFirstpollution());
					cityinfo.setPollutionLevel(air.getPollutionlevel());
					cityinfo.setConcenPM2p5(air.getConcenpm2p5());
					cityinfo.setFractPM2p5(air.getFractpm2p5());
					cityinfo.setConcenPM10(air.getConcenpm10());
					cityinfo.setFractPM10(air.getFractpm10());
					cityinfo.setConcenCO(air.getConcenco());
					cityinfo.setFractCO(air.getFractco());
					cityinfo.setConcenO3(air.getConceno3());
					cityinfo.setFractO3(air.getFracto3());
					cityinfo.setConcenO38H(air.getConceno38h());
					cityinfo.setFractO38H(air.getFracto38h());
					cityinfo.setConcenSO2(air.getConcenso2());
					cityinfo.setFractSO2(air.getFractso2());
					cityinfo.setConcenNO2(air.getConcenno2());
					cityinfo.setFractNO2(air.getFractno2());
					resultList.add(cityinfo);
				}
			}
		}
		return resultList;
	}



	@Override
	public List<airpollution> syeverydaysk() {
		List<airpollution> listData = new ArrayList<airpollution>();
		Map<String, String> selectParam = new HashMap<String, String>();
		RequestDataBySelect selectRequest = new RequestDataBySelect();
		List<String> columns = new ArrayList<String>();
		columns.add("to_char(observtime, 'yyyy-MM-dd HH24:MI:SS') as observtime");
		selectRequest.setColumns(columns.toArray(new String[columns.size()]));
		// 拼接where字段
		StringBuilder strWhere = new StringBuilder();
		strWhere.append(String.format("stationid!='%s'", "Qs"));
		selectRequest.setParam(strWhere.toString());
		selectRequest.setSort(new String[]{"observtime desc"});
		selectRequest.setLimit(1);
		try {
			selectParam.put("method", "airpollution");
			selectParam.put("sqlType", "select");
			selectParam.put("advCode", DbConfig.advCode);
			selectParam.put("param", JsonUtil.object2Json(selectRequest));
			String message =procon.processRequest(selectParam);
			listData = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<airpollution>>() {
			});
			if (listData != null && listData.size() > 0) {
				selectParam = new HashMap<String, String>();
				selectRequest = new RequestDataBySelect();
				// 拼接where字段
				strWhere = new StringBuilder();
				strWhere.append(String.format("stationid!='%s'", "Qs"));
				if (listData.get(0).getObservtime() != null) {
					strWhere.append(String.format(" and observtime='" + listData.get(0).getObservtime() + "'"));
				}
				selectRequest.setParam(strWhere.toString());
				try {
					selectParam.put("method", "airpollution");
					selectParam.put("sqlType", "select");
					selectParam.put("advCode", DbConfig.advCode);
					selectParam.put("param", JsonUtil.object2Json(selectRequest));
					message = procon.processRequest(selectParam);
					listData = JsonUtil.jsonStr2TypeReference(message, new TypeReference<List<airpollution>>() {
					});

				} catch (Exception e) {
					// TODO: handle exception
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		return listData;
	}

}
